import { defineConfig } from "vite";
import { fileURLToPath, URL } from "node:url";

import vue from "@vitejs/plugin-vue";
const baseUrl = "http://47.105.71.118:8080"; // 后端接口
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/assets/style/elementui-variables.scss" as *;`,
      },
    },
  },
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  // vite 相关配置
  server: {
    port: 80,
    host: true,
    open: true,
    proxy: {
      // https://cn.vitejs.dev/config/#server-proxy
      "/dev-api": {
        target: baseUrl,
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/dev-api/, ""),
      },
      // springdoc proxy
      "^/v3/api-docs/(.*)": {
        target: baseUrl,
        changeOrigin: true,
      },
    },
  },
});
